home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
apps
/
439
/
draw3
/
draw3.lst
next >
Wrap
File List
|
1990-11-30
|
7KB
|
246 lines
` Drawing program using mouse and mouse buttons
' by E.C. Smith July 23, 1989 for S.P.A.C.E ST SIG
'
Dim X%(16) !Array to hold x coordinates of the color boxes displayed
Dim Sx%(4) !Array to hold x coordinates of the size boxes
Offset%=4950 !Draw on lower portion of screen only
R%=10 !Initial radius of circles
S%=10 !Initial side of squares
C%=1 !Establish color register 1 to start
W4%=36 ! width of a 4 letter box
H4%=10 ! height " " " " "
Xq%=0 ! location of
Yq%=0 ! quit box
Brush%=2 ! Brush size is a fine point
R%=10 ! Set radius
Wbr%=248 ! width of brush selection screen
Hbr%=120 ! height of brush selection screen
Xbr%=16 ! location of
Ybr%=40 ! brush selection screen
Xclr%=0 ! location
Yclr%=11 ! clear screen box
Xsave%=W4%+4 ! location of
Ysave%=0 ! save box
Xload%=W4%+4 ! location of
Yload%=11 ! load box
Xbrsh%=2*W4%+8 ! location of
Ybrsh%=11 ! Brsh box
Get 0,0,W4%,H4%,X4$ ! Size of 4 letter box
Mid$(X4$,7)=String$(Len(X4$),255) ! Fill X4$ with binary one"s
Get 0,0,Wbr%,Hbr%,Blank$
Mid$(Blank$,7)=String$(Len(Blank$),0)
W%=10 ! width of color box
H%=10 ! height of color box
D%=8 ! distance between boxes
X1%=19 ! leftmost color box position
Y1%=22 ! distance from top of screen
@Plot_upper_screen
Do ! DO loop to look for mouse button press (left or right buttons)
Inc I% ! increment to next color box
If I%>15 ! Only 16 boxes possible (0 to 15)
I%=0
Endif
Xa%=X%(I%) ! Get X% location of box I%
K%=Mousek ! Look for press of mouse button
X%=Mousex ! Get location of
Y%=Mousey ! mouse on screen
If X%>Xa% And X%<Xa%+W% And Y%<Y1%+H% And Y%>Y1% And K%=1
C%=Point(X%,Y%) ! Color box was entered, get color value of this box
Endif
If X%>Xq% And X%<Xq%+W4% And Y%<Yq%+H4% And Y%>Yq% And K%=1
Done!=True ! quit box was entered, we are done!
Put Xq%,Yq%,X4$,6
Endif
If X%>Xsave% And X%<Xsave%+W4% And Y%<Ysave%+H4% And Y%>Ysave% And K%=1
Put Xsave%,Ysave%,X4$,6 ! Save box was entered
@Get_default_drive
@Get_filename
If Not Cancel!
Print At(21,2);"Saving file "
Bsave File$,Xbios(2)+Offset%,32000-Offset%
Endif
Put Xsave%,Ysave%,X4$,6
Print At(21,2);" "
Endif
If X%>Xload% And X%<Xload%+W4% And Y%<Yload%+H4% And Y%>Yload% And K%=1
Put Xload%,Yload%,X4$,6 ! Load box was entered
@Get_default_drive
@Get_filename
If (Not Cancel!) And (Exist(File$))
Print At(21,2);"Loading File"
Bload File$,Xbios(2)+Offset%
Endif
Put Xload%,Yload%,X4$,6
Print At(21,2);" "
Endif
If X%>Xbrsh% And X%<Xbrsh%+W4% And Y%<Ybrsh%+H4% And Y%>Ybrsh% And K%=1
Put Xbrsh%,Ybrsh%,X4$,6 ! Brsh box was entered
Get Xbr%,Ybr%,Xbr%+Wbr%,Ybr%+Hbr%,Y$ ! get screen
Put Xbr%,Ybr%,Blank$ ! Replace screen with blank
Deffill C%
Color C%
Box Xbr%,Ybr%,Xbr%+Wbr%,Ybr%+Hbr% ! Draw border box
Box Xbr%+4,Ybr%+4,Xbr%+Wbr%-4,Ybr%+Hbr%-4 ! Draw inside border box
@Get_brush(C%) ! Get brush% r% or s%
Put Xbr%,Ybr%,Y$ ! Restore screen
Put Xbrsh%,Ybrsh%,X4$,6 ! outen Brsh box
Endif
If X%>Xclr% And X%<Xclr%+W4% And Y%<Yclr%+H4% And Y%>Yclr% And K%=1
Put Xclr%,Yclr%,X4$,6 !ClrS box entered
Cls
@Plot_upper_screen
Endif
If K%=1 And Y%>Y1%+H%
Color C% ! Plot color by pressing left button
On Brush% Gosub Solid_cir,Empty_cir,Solid_squ,Empty_squ
Endif
Exit If Done! ! Exit by clicking on exit box
Loop
End
Procedure Get_filename
Cancel!=False
Fs$=Drv$+"\*.pix"
Repeat
Fileselect Fs$,B$,File$
Until File$<>Drv$+"\"
If File$=""
Cancel!=True
Endif
Return
Procedure Get_default_drive
Drv$=Chr$(Gemdos(25)+65)+":"
Return
Procedure Plot_upper_screen
Box Xq%,Yq%,Xq%+W4%,Yq%+H4% ! Plot quit box
Text Xq%+2,Yq%+H4%-2,"Quit" ! Put text in box
Box Xsave%,Ysave%,Xsave%+W4%,Ysave%+H4% ! Plot Save box
Text Xsave%+2,Ysave%+H4%-2,"Save" ! Put text in box
Box Xload%,Yload%,Xload%+W4%,Yload%+H4% ! Plot load box
Text Xload%+2,Yload%+H4%-2,"Load" ! Put text in box
Box Xclr%,Yclr%,Xclr%+W4%,Yclr%+H4% ! Plot ClrS box
Text Xclr%+2,Yclr%+H4%-2,"ClrS" ! Put text in box
Box Xbrsh%,Ybrsh%,Xbrsh%+W4%,Ybrsh%+H4% ! Plot Brsh box
Text Xbrsh%+2,Ybrsh%+H4%-2,"Brsh" ! Put text in box
For I%=0 To 15 ! This FOR NEXT loop
X%=X1%+(W%+D%)*I%
X%(I%)=X% ! plots 16 color boxes
Color I%
Deffill I%
Pbox X%,Y1%,X%+W%,Y1%+H% ! across the upper portion of the screen.
If I%<4
Sx%(I%)=Xbr%+16+60*I% ! Fill Size box array (X% values)
Endif
Next I%
Return
Procedure Solid_cir
Deffill C%
Pcircle X%,Y%,R%
Return
Procedure Empty_cir
Deffill C%
If R%<>1
Circle X%,Y%,R%
Else
Plot X%,Y%
Endif
Return
Procedure Solid_squ
Deffill C%
Pbox X%,Y%,X%+S%,Y%+S%
Return
Procedure Empty_squ
Deffill C%
Box X%,Y%,X%+S%,Y%+S%
Return
Procedure Get_brush(C%)
' Determine brush%=1 to 4 and values for r% and s%
Gotbrush!=False
Print At(4,7);"B R U S H S E L E C T I O N"
Print At(4,8);"To adjust brush size click on"
Print At(4,9);"Size box using left button"
Print At(4,10);"until satisfied."
Print At(4,18);"To select a brush click on"
Print At(4,19);"Size box using right button"
Pcircle Xbr%+40,Ybr%+70,R%
Circle Xbr%+100,Ybr%+70,R%
Pbox Xbr%+150,Ybr%+70-R%/2,Xbr%+150+S%,Ybr%+70+S%-R%/2
Box Xbr%+200,Ybr%+70-R%/2,Xbr%+200+S%,Ybr%+70+S%-R%/2
Ysize%=Ybr%+84
For I%=0 To 3
Box Sx%(I%),Ysize%,Sx%(I%)+W4%,Ysize%+H4%
Text Sx%(I%)+2,Ysize%+H4%-2,"Size"
Next I%
I%=0
@Circle2
I%=1
@Circle2
I%=2
@Square2
I%=3
@Square2
Do
Inc I%
If I%>3
I%=0
Endif
X%=Mousex
Y%=Mousey
K%=Mousek
If X%>Sx%(I%) And X%<Sx%(I%)+W4% And Y%<Ysize%+H4% And Y%>Ysize%
If K%=2
Brush%=I%+1
Gotbrush!=True
Endif
If K%=1 And I%<2
Inc R%
If R%>14
R%=1
Endif
@Circle2
If I%=0
Deffill 0
Pcircle Xbr%+40,Ybr%+70,14
Deffill C%
Pcircle Xbr%+40,Ybr%+70,R%
Endif
If I%=1
Deffill 0
Pcircle Xbr%+100,Ybr%+70,14
Deffill C%
Circle Xbr%+100,Ybr%+70,R%
Endif
Endif
If K%=1 And I%>1
Inc S%
If S%>14
S%=1
Endif
@Square2
If I%=2
Deffill 0
Pbox Xbr%+150,Ybr%+70-R%/2,Xbr%+164,Ybr%+84-R%/2
Deffill C%
Pbox Xbr%+150,Ybr%+70-R%/2,Xbr%+150+S%,Ybr%+70+S%-R%/2
Endif
If I%=3
Deffill 0
Pbox Xbr%+200,Ybr%+70-R%/2,Xbr%+214,Ybr%+84-R%/2
Deffill C%
Box Xbr%+200,Ybr%+70-R%/2,Xbr%+200+S%,Ybr%+70+S%-R%/2
Endif
Endif
Endif
Exit If Gotbrush!
Loop
Return
Procedure Circle2
L%=5*(I%=0)*(-1)+13*(I%=1)*(-1)
Print At(L%,12);" "
Print At(L%,12);C%;" ";R%
Return
Procedure Square2
L%=20*(I%=2)*(-1)+27*(I%=3)*(-1)
Print At(L%,12);" "
Print At(L%,12);C%;" ";S%
Return